import 'dart:convert';

class PostDetailEntity {
  int? code = 0;
  String? message = '';
  PostDetailData? data;
  int? timestamp = 0;

  PostDetailEntity();

  factory PostDetailEntity.fromJson(Map<String, dynamic> json) {
    return PostDetailEntity()
      ..code = json['code']
      ..message = json['message']
      ..data =
          json['data'] != null ? PostDetailData.fromJson(json['data']) : null
      ..timestamp = json['timestamp'];
  }

  Map<String, dynamic> toJson() {
    return {
      'code': code,
      'message': message,
      'data': data?.toJson(),
      'timestamp': timestamp,
    };
  }

  @override
  String toString() {
    return jsonEncode(this);
  }
}

class PostDetailData {
  int? id = 0;
  String? title = '';
  String? content = '';
  String? createTime = '';
  int? state = 0;

  PostDetailData();

  factory PostDetailData.fromJson(Map<String, dynamic> json) {
    return PostDetailData()
      ..id = json['id']
      ..title = json['title']
      ..content = json['content']
      ..createTime = json['createTime']
      ..state = json['state'];
  }

  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'title': title,
      'content': content,
      'createTime': createTime,
      'state': state,
    };
  }

  @override
  String toString() {
    return jsonEncode(this);
  }
}
